package test1224;

public class Test18 {
    public static void m18(int[] arr, int[] brr) {
        int[] diff = new int[arr.length];
        int index = 0;
        for (int i = 0; i < arr.length; i++){
            boolean found = false;
            for (int j = 0; j < brr.length; j++){
                if (arr[i] == brr[j]){
                    found = true;
                    break;
                }
            }
            if (found == false) {
                diff[index] = arr[i];
                index++;
            }
        }
        System.out.println("数组arr-brr的差集结果为: " );
        for (int i = 0; i < index; i++){
            System.out.print(diff[i] + " ");
        }


    }
    public static void main(String[] args) {
        // 根据方法的调用需求实现方法
        // 打印arr与brr的差集(arr中有brr中没有的元素)
        int[] arr = {1,2,3,4,5};
        int[] brr = {3,4,5,6,7};
        m18(arr, brr);
    }
}